export default {
	status:{
		//登陆状态
		loginStatus:false,
		//用户信息
		userInfo:{
			openID:""
		}
	},
	getters:{},
	mutations:{
		//登陆后保存用户信息
		login(state,userInfo){
			state.userInfo = userInfo;
			state.loginStatus =true;
			//持久化存储
			uni.setStorageSync('userInfo', JSON.stringify(userInfo)); //把对象转成字符串
		},
		
		//退出登陆
		logout(state){
			state.loginStatus = false;
			state.userInfo = {};
			//删除本地存储的信息
			uni.removeStorageSync('userInfo');
		},
		
		
		//进入小程序,就要执行这个方法,把用户信息读出来
		initUser(state){
			let userInfo = uni.getStorageSync('userInfo');
			if(userInfo){
				userInfo = JSON.parse(userInfo);
				state.userInfo = userInfo;
				state.loginStatus =true;
			}
		}
	},
	actions:{}
}